﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Project
{
    public partial class passwordReset : System.Web.UI.Page
    {
#region Navid_code
       //If found any problem let me know
        static string connectionString = ConfigurationManager.ConnectionStrings["StudentAdvisorString"].ConnectionString;
        SqlConnection connection = new SqlConnection(connectionString);
        SqlCommand updatePassword = null;
        //SqlDataReader readAnswer = null;
        String s = null;
  

        protected void Page_Load(object sender, EventArgs e)
        {
            s = Session["userID"].ToString().Trim();
        }

        protected void btn_resetPassword_Click(object sender, EventArgs e)
        {
    

            connection.Open();
            string resetPassword = "update tblUserLogin set Password = '" + txt_password.Text + "' where UserId= '" + s +"'";
            lbl_userName.Text = resetPassword;
            updatePassword = new SqlCommand(resetPassword, connection);
            int i = 0;
            try
            {
                i = updatePassword.ExecuteNonQuery();
            }
            catch (SqlException sqle) {
                lbl_error.Text = sqle.Message;
            }
            if (i == 1) { 
                Response.Redirect("studentProfile_.aspx");
            }
            connection.Close();
        }
#endregion Navid_code
    }

}